home *** CD-ROM | disk | FTP | other *** search
- #include<stdio.h>
- #include<stdarg.h>
- #include<LowMem.h>
-
- #pragma mark Globals
-
- WindowPtr theWindow;
- Boolean gDone=false;
- unsigned long gFilter = 0;
- GWorldPtr gBraveNewGWorld;
-
- #pragma mark Protos
-
- void dprintf(char *format, ...);
- void InitToolbox(void);
- void Invert(Rect *);
- void Dim(Rect *);
- void Blur(Rect *);
- void Apple2(Rect *);
- void Flip(Rect *);
- void NoBlue(Rect *);
- void Trace(Rect *);
- void Right(Rect *);
- void Left(Rect *);
- void DarkBlur(Rect *baz);
- void Mouse(Point pt, Rect rect);
- void MainLoop(Rect rect);
- void ApplyFilters(Rect *baz);
- void Menu(unsigned long menuselectinfo);
- void MenuStuff(void);
- void Intro(void);
- void Nostalgia(Rect*);
-
- void InitToolbox(void)
- {
- InitGraf(&qd.thePort);
- InitCursor();
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs(nil);
- InitFonts();
-
- FlushEvents(everyEvent, nil);
- }
-
- void ApplyFilters(Rect *baz)
- {
- int i;
- GWorldPtr temp;
- GDHandle tempGD;
-
- GetGWorld(&temp, &tempGD);
- SetGWorld(gBraveNewGWorld, nil);
- for(i=0;i<32;i++)
- {
- if(gFilter & 1 << i)
- {
- switch(i)
- {
- case 0:
- Dim(baz);
- break;
- case 1:
- Trace(baz);
- break;
- case 2:
- Flip(baz);
- break;
- case 3:
- Invert(baz);
- break;
- case 4:
- Blur(baz);
- break;
- case 5:
- Apple2(baz);
- break;
- case 6:
- Right(baz);
- break;
- case 7:
- Left(baz);
- break;
- case 8:
- Nostalgia(baz);
- break;
- default:
- break;
- }
- }
- }
- SetGWorld(temp, tempGD);
- }
-
- void MainLoop(Rect rect)
- {
- EventRecord event;
- CGrafPtr screen;
- Point tempPoint;
- Rect theRect;
- EventRecord theEvent;
- GWorldPtr temp;
- GDHandle tempGD;
-
- while(!gDone)
- {
- if(WaitNextEvent(everyEvent, &event, 0xFFFFFFF, nil))
- {
- switch(event.what)
- {
- case mouseDown:
- Mouse(event.where, rect);
- break;
- case keyDown:
- if( (event.modifiers & cmdKey) != 0 ) {
- Menu( MenuKey(event.message & charCodeMask ) );
- rect=theWindow->portRect;
- SetPort(theWindow);
- tempPoint.h=0;
- tempPoint.v=0;
- LocalToGlobal(&tempPoint);
- OffsetRect(&theRect, tempPoint.h, tempPoint.v);
- GetCWMgrPort(&screen);
- HideWindow(theWindow);
- WaitNextEvent(0, &theEvent, 5, nil);
- LockPixels(GetGWorldPixMap(gBraveNewGWorld));
- CopyBits(&((GrafPtr)screen)->portBits, &((GrafPtr)gBraveNewGWorld)->portBits,
- &theRect, &rect, nil, nil);
- ShowWindow(theWindow);
- GetGWorld(&temp, &tempGD);
- SetGWorld(gBraveNewGWorld, nil);
- ApplyFilters(&rect);
- CopyBits(&((GrafPtr)gBraveNewGWorld)->portBits, &((GrafPtr)theWindow)->portBits,
- &rect, &theWindow->portRect, nil, nil);
- UnlockPixels(GetGWorldPixMap(gBraveNewGWorld));
- }
- break;
- case updateEvt:
- BeginUpdate((WindowPtr)event.message);
- /* HideWindow(theWindow);
- GetCWMgrPort(&screen);
-
- CopyBits(&((GrafPtr)screen)->portBits, &((GrafPtr)gBraveNewGWorld)->portBits,
- &theWindow->portRect, &rect, nil, nil);
- ShowWindow(theWindow);
- GetGWorld(&temp, &tempGD);
- SetGWorld(gBraveNewGWorld, nil);
-
-
- ApplyFilters(&rect);*/
- LockPixels(GetGWorldPixMap(gBraveNewGWorld));
- CopyBits(&((GrafPtr)gBraveNewGWorld)->portBits, &((GrafPtr)theWindow)->portBits,
- &theWindow->portRect, &rect, nil, nil);
- UnlockPixels(GetGWorldPixMap(gBraveNewGWorld));
- EndUpdate((WindowPtr)event.message);
- InitCursor();
- break;
- }
- }
- /* CopyBits(&((GrafPtr)gBraveNewGWorld)->portBits, &((GrafPtr)theWindow)->portBits,
- &rect, &rect, nil, nil); */
- }
- }
-
- void Mouse(Point pt, Rect rect)
- {
- WindowPtr which;
- short where;
- Rect limits;
- Point tempPoint;
- Rect theRect;
-
- GWorldPtr temp;
- CGrafPtr screen;
- GDHandle tempGD;
- EventRecord theEvent;
- // Rect tempRect;
- SetRect(&limits, -32767, -32767, 32767, 32767);
-
- SetRect(&theRect, 0, 0, 240, 240);
- where = FindWindow(pt, &which);
- switch(where)
- {
- case inMenuBar:
- Menu(MenuSelect(pt));
- case inDrag:
- SelectWindow(theWindow);
- DragWindow(theWindow, pt, &limits);
- rect=theWindow->portRect;
- SetPort(theWindow);
- tempPoint.h=0;
- tempPoint.v=0;
- LocalToGlobal(&tempPoint);
- OffsetRect(&theRect, tempPoint.h, tempPoint.v);
- GetCWMgrPort(&screen);
- HideWindow(theWindow);
- WaitNextEvent(0, &theEvent, 5, nil);
- LockPixels(GetGWorldPixMap(gBraveNewGWorld));
- CopyBits(&((GrafPtr)screen)->portBits, &((GrafPtr)gBraveNewGWorld)->portBits,
- &theRect, &rect, nil, nil);
- ShowWindow(theWindow);
- GetGWorld(&temp, &tempGD);
- SetGWorld(gBraveNewGWorld, nil);
- ApplyFilters(&rect);
- CopyBits(&((GrafPtr)gBraveNewGWorld)->portBits, &((GrafPtr)theWindow)->portBits,
- &rect, &theWindow->portRect, nil, nil);
- UnlockPixels(GetGWorldPixMap(gBraveNewGWorld));
- break;
- case inContent:
- LockPixels(GetGWorldPixMap(gBraveNewGWorld));
- GetGWorld(&temp, nil);
- SetGWorld(gBraveNewGWorld, nil);
- ApplyFilters(&rect);
-
- CopyBits(&((GrafPtr)gBraveNewGWorld)->portBits, &((GrafPtr)theWindow)->portBits,
- &rect, &rect, nil, nil);
- SetGWorld(temp, nil);
- UnlockPixels(GetGWorldPixMap(gBraveNewGWorld));
- break;
- case inGoAway:
- gDone=true;
- break;
- }
- }
-
- void Menu(unsigned long result) {
- unsigned long *temp;
-
- result &= 0xFFFF;
- if(result > 2) {
- gFilter ^= 1UL << (result-3);
- CheckItem( GetMenu(128), result, (gFilter & (1UL << (result-3UL))) != 0UL );
- } else if(result == 1) {
- Gestalt('AltS', (long*)&temp);
- if(temp)
- *temp = gFilter;
- PaintBehind(theWindow, LMGetGrayRgn());
- CalcVisBehind(theWindow, LMGetGrayRgn());
- DrawMenuBar();
- }
- HiliteMenu(0);
- }
-
- void MenuStuff(void) {
- long *temp;
- long foo;
-
- InsertMenu( GetMenu(128), 0 );
- DrawMenuBar();
-
- Gestalt('AltS', (long*)&temp);
- if(temp)
- gFilter = *temp;
- else
- gFilter = 0;
-
- for(foo = 0; foo < 32; foo++) {
- if( gFilter & 1UL << foo)
- CheckItem( GetMenu(128), foo+3, true );
- }
- }
-
- void Intro(void)
- {
- PicHandle introPic;
- Rect introRect;
- WindowPtr introWindow;
- EventRecord theEvent;
-
- SetRect(&introRect, 0, 0, 548, 229);
-
- introPic=GetPicture(128);
-
- OffsetRect(&introRect, (qd.screenBits.bounds.right/2)-(548/2), (qd.screenBits.bounds.bottom/2)-(229/2));
- introWindow=NewCWindow(introWindow, &introRect, "\pDrugTest", true, 2, (WindowPtr)-1, true, nil);
- SetPort(introWindow);
-
- SetRect(&introRect, 0, 0, 548, 229);
- DrawPicture(introPic, &introRect);
-
- while(!Button())
- ;
-
- DisposeWindow(introWindow);
- WaitNextEvent(0, &theEvent, 5, nil);
- FlushEvents(everyEvent, nil);
- }
-
- void main(void)
- {
- CGrafPtr screen;
- GWorldPtr temp;
- GDHandle tempGD;
- Rect rect, windRect;
-
- InitToolbox();
- Intro();
- SetRect(&rect, 0, 0, 240, 240);
- windRect=rect;
- OffsetRect(&windRect, 100, 100);
- GetCWMgrPort(&screen);
- NewGWorld(&gBraveNewGWorld, 32, &rect, nil, nil, nil);
- CopyBits(&((GrafPtr)screen)->portBits, &((GrafPtr)gBraveNewGWorld)->portBits,
- &windRect, &rect, nil, nil);
- theWindow=NewWindow(theWindow, &windRect, "\pDrugTest", true, documentProc, (WindowPtr)-1, true, nil);
-
- GetGWorld(&temp, &tempGD);
- SetGWorld(gBraveNewGWorld, nil);
-
- LockPixels(GetGWorldPixMap(gBraveNewGWorld));
-
- ApplyFilters(&rect);
-
- CopyBits(&((GrafPtr)gBraveNewGWorld)->portBits, &((GrafPtr)theWindow)->portBits,
- &rect, &rect, nil, nil);
-
- MenuStuff();
-
- UnlockPixels(GetGWorldPixMap(gBraveNewGWorld));
-
- while(!gDone)
- MainLoop(rect);
-
- DisposeWindow(theWindow);
- DisposeGWorld(gBraveNewGWorld);
- SetGWorld(temp, tempGD);
-
- FlushEvents(everyEvent, nil);
- }
-
- void Dim(Rect *baz) {
- PixMapHandle bar = GetGWorldPixMap(gBraveNewGWorld);
- unsigned long rbytes = bar[0]->rowBytes & 0x3FFF;
- Rect foo = bar[0]->bounds;
- Ptr data = GetPixBaseAddr(GetGWorldPixMap(gBraveNewGWorld));
- long x, y;
- unsigned long *pixelptr;
-
- if(!data) {
- DebugStr("\pthe pixbaseaddr of our gworld is nil");
- return;
- }
-
- for(y = baz->top; y < baz->bottom; y++) {
- for(x = baz->left; x < baz->right; x++) {
- pixelptr = (unsigned long*)(data + (y * rbytes) + (x * 4));
- *pixelptr -= (*pixelptr & 0xF0F0F0F0) >> 4;
- // *(unsigned long*)(data + (y * rbytes) + (x * 4)) >>= 1;
- }
- }
- }
-
- void Blur(Rect *baz) {
- PixMapHandle bar = GetGWorldPixMap(gBraveNewGWorld);
- unsigned long rbytes = (bar[0]->rowBytes & 0x3FFF) >> 2;
- Ptr data = GetPixBaseAddr(GetGWorldPixMap(gBraveNewGWorld));
- long x, y;
- unsigned long *pixelptr;
-
- if(!data) {
- DebugStr("\pthe pixbaseaddr of our gworld is nil");
- return;
- }
-
- pixelptr = (unsigned long*)(data + (baz->top * (rbytes<<2)) + (baz->left * 4));
- *pixelptr = ((*pixelptr & 0xFEFEFEFE) >> 1) +
- ( ( (*(pixelptr + 1) & 0xFCFCFCFC) | 0x04040404) >> 2) +
- ( ( (*(pixelptr + rbytes) & 0xFCFCFCFC) | 0x04040404) >> 2);
-
- pixelptr = (unsigned long*)(data + ((baz->bottom-1) * (rbytes<<2)) + (baz->left * 4));
- *pixelptr = ((*pixelptr & 0xFEFEFEFE) >> 1) +
- ( ( (*(pixelptr + 1) & 0xFCFCFCFC) | 0x04040404) >> 2) +
- ( ( (*(pixelptr - rbytes) & 0xFCFCFCFC) | 0x04040404) >> 2);
-
- pixelptr = (unsigned long*)(data + (baz->top * (rbytes<<2)) + ((baz->right-1) * 4));
- *pixelptr = ((*pixelptr & 0xFEFEFEFE) >> 1) +
- ( ( (*(pixelptr - 1) & 0xFCFCFCFC) | 0x04040404) >> 2) +
- ( ( (*(pixelptr + rbytes) & 0xFCFCFCFC) | 0x04040404) >> 2);
-
- pixelptr = (unsigned long*)(data + ((baz->bottom-1) * (rbytes<<2)) + ((baz->right-1) * 4));
- *pixelptr = ((*pixelptr & 0xFEFEFEFE) >> 1) +
- ( ( (*(pixelptr - 1) & 0xFCFCFCFC) | 0x04040404) >> 2) +
- ( ( (*(pixelptr - rbytes) & 0xFCFCFCFC) | 0x04040404) >> 2);
-
- for(x = baz->left + 1; x < baz->right - 1; x++) {
- pixelptr = (unsigned long*)(data + (baz->top * (rbytes<<2)) + (x * 4));
- *pixelptr = ((*pixelptr & 0xFEFEFEFE) >> 1) +
- ( ( (*(pixelptr - 1) & 0xF8F8F8F8) | 0x08080808) >> 3) +
- ( ( (*(pixelptr + 1) & 0xF8F8F8F8) | 0x08080808) >> 3) +
- ( ( (*(pixelptr + rbytes) & 0xFCFCFCFC) | 0x04040404) >> 2);
-
- pixelptr = (unsigned long*)(data + ((baz->bottom-1) * (rbytes<<2)) + (x * 4));
- *pixelptr = ((*pixelptr & 0xFEFEFEFE) >> 1) +
- ( ( (*(pixelptr - 1) & 0xF8F8F8F8) | 0x08080808) >> 3) +
- ( ( (*(pixelptr + 1) & 0xF8F8F8F8) | 0x08080808) >> 3) +
- ( ( (*(pixelptr - rbytes) & 0xFCFCFCFC) | 0x04040404) >> 2);
- }
-
- for(y = baz->top + 1; y < baz->bottom - 1; y++) {
- pixelptr = (unsigned long*)(data + (y * (rbytes<<2)) + (baz->left * 4));
- *pixelptr = ((*pixelptr & 0xFEFEFEFE) >> 1) +
- ( ( (*(pixelptr + 1) & 0xFCFCFCFC) | 0x04040404) >> 2) +
- ( ( (*(pixelptr - rbytes) & 0xF8F8F8F8) | 0x08080808) >> 3) +
- ( ( (*(pixelptr + rbytes) & 0xF8F8F8F8) | 0x08080808) >> 3);
-
- pixelptr = (unsigned long*)(data + (y * (rbytes<<2)) + ((baz->right-1) * 4));
- *pixelptr = ((*pixelptr & 0xFEFEFEFE) >> 1) +
- ( ( (*(pixelptr - 1) & 0xFCFCFCFC) | 0x04040404) >> 2) +
- ( ( (*(pixelptr - rbytes) & 0xF8F8F8F8) | 0x08080808) >> 3) +
- ( ( (*(pixelptr + rbytes) & 0xF8F8F8F8) | 0x08080808) >> 3);
- }
-
- for(y = baz->top + 1; y < baz->bottom - 1; y++) {
- for(x = baz->left + 1; x < baz->right - 1; x++) {
- pixelptr = (unsigned long*)(data + (y * (rbytes<<2)) + (x * 4));
- *pixelptr = ((*pixelptr & 0xFEFEFEFE) >> 1) +
- ( ( (*(pixelptr - 1) & 0xF8F8F8F8) | 0x08080808) >> 3) +
- ( ( (*(pixelptr + 1) & 0xF8F8F8F8) | 0x08080808) >> 3) +
- ( ( (*(pixelptr - rbytes) & 0xF8F8F8F8) | 0x08080808) >> 3) +
- ( ( (*(pixelptr + rbytes) & 0xF8F8F8F8) | 0x08080808) >> 3);
- }
- }
- }
-
- void Apple2(Rect *baz) {
- PixMapHandle bar = GetGWorldPixMap(gBraveNewGWorld);
- unsigned long rbytes = bar[0]->rowBytes & 0x3FFF;
- Ptr data = GetPixBaseAddr(GetGWorldPixMap(gBraveNewGWorld));
- long x, y;
- unsigned long *pixelptr;
- unsigned short quux;
-
- if(!data) {
- DebugStr("\pthe pixbaseaddr of our gworld is nil");
- return;
- }
-
- for(y = baz->top; y < baz->bottom; y++) {
- for(x = baz->left; x < baz->right; x++) {
- pixelptr = (unsigned long*)(data + (y * rbytes) + (x * 4));
- quux = ((unsigned char*)pixelptr)[1];
- quux += ((unsigned char*)pixelptr)[3];
- quux >>= 1;
- ((unsigned char*)pixelptr)[1] = ((unsigned char*)pixelptr)[3] = quux;
- }
- }
- }
-
- void Flip(Rect *baz) {
- PixMapHandle bar = GetGWorldPixMap(gBraveNewGWorld);
- unsigned long rbytes = bar[0]->rowBytes & 0x3FFF;
- Ptr data = GetPixBaseAddr(GetGWorldPixMap(gBraveNewGWorld));
- long x, y;
- unsigned long *top, *bottom;
- unsigned long temp;
-
- if(!data) {
- DebugStr("\pthe pixbaseaddr of our gworld is nil");
- return;
- }
-
- for(y = baz->top; y < baz->bottom - ((baz->bottom - baz->top + 1)>>1); y++) {
- for(x = baz->left; x < baz->right; x++) {
- top = (unsigned long*)(data + (y * rbytes) + (x * 4));
- bottom = (unsigned long*)(data + ((baz->bottom - y - 1) * rbytes) + (x * 4));
- temp = *bottom;
- *bottom = *top;
- *top = temp;
- }
- }
- }
-
- void NoBlue(Rect *baz) {
- PixMapHandle bar = GetGWorldPixMap(gBraveNewGWorld);
- unsigned long rbytes = bar[0]->rowBytes & 0x3FFF;
- Ptr data = GetPixBaseAddr(GetGWorldPixMap(gBraveNewGWorld));
- long x, y;
- unsigned long *pixelptr;
- short temp;
-
- if(!data) {
- DebugStr("\pthe pixbaseaddr of our gworld is nil");
- return;
- }
-
- for(y = baz->top; y < baz->bottom; y++) {
- for(x = baz->left; x < baz->right; x++) {
- pixelptr = (unsigned long*)(data + (y * rbytes) + (x * 4));
- temp = ((unsigned char*)pixelptr)[1] + ((unsigned char*)pixelptr)[2];
- ((unsigned char*)pixelptr)[3] = temp>>1;
- }
- }
- }
-
- void Trace(Rect *baz) {
- PixMapHandle bar = GetGWorldPixMap(gBraveNewGWorld);
- unsigned long rbytes = (bar[0]->rowBytes & 0x3FFF)>>2;
- Ptr data = GetPixBaseAddr(GetGWorldPixMap(gBraveNewGWorld));
- long x, y;
- unsigned long *from, *to;
- unsigned long comp;
- unsigned long *buffer = (unsigned long *)NewPtr( (baz->right - baz->left) * (baz->bottom - baz->top) * 4 );
-
- if(!data) {
- DebugStr("\pthe pixbaseaddr of our gworld is nil");
- return;
- }
-
- if(!buffer) {
- DebugStr("\pthe buffer is nil");
- return;
- }
-
- for(y = baz->top; y < baz->bottom; y++) {
- for(x = baz->left; x < baz->right; x++) {
- from = (unsigned long*)(data + (y * (rbytes<<2)) + (x * 4));
- to = buffer + y*(baz->right - baz->left) + x;
-
- comp =
- ( ( *(from - 1) & 0xFCFCFCFC) >> 2) +
- ( ( *(from + 1) & 0xFCFCFCFC) >> 2) +
- ( ( *(from - rbytes) & 0xFCFCFCFC) >> 2) +
- ( ( *(from + rbytes) & 0xFCFCFCFC) >> 2);
-
- if( ((char*)from)[1] > ((char*)&comp)[1] )
- ((char*)to)[1] = ((char*)from)[1] - ((char*)&comp)[1];
- else
- ((char*)to)[1] = ((char*)&comp)[1] - ((char*)from)[1];
-
- if( ((char*)from)[2] > ((char*)&comp)[2] )
- ((char*)to)[2] = ((char*)from)[2] - ((char*)&comp)[2];
- else
- ((char*)to)[2] = ((char*)&comp)[2] - ((char*)from)[2];
-
- if( ((char*)from)[3] > ((char*)&comp)[3] )
- ((char*)to)[3] = ((char*)from)[3] - ((char*)&comp)[3];
- else
- ((char*)to)[3] = ((char*)&comp)[3] - ((char*)from)[3];
- }
- }
- for(y = baz->top; y < baz->bottom; y++) {
- for(x = baz->left; x < baz->right; x++) {
- *(unsigned long*)(data + (y * (rbytes<<2)) + (x * 4)) = buffer[y*(baz->right - baz->left) + x];
- }
- }
- DisposePtr((char*)buffer);
- }
- /*
- * DebugStr() + printf() = very useful function
- */
- void dprintf(char *format, ...) {
- va_list args;
- char dbugstr[256];
-
- va_start(args, format);
- vsprintf(dbugstr, format, args);
- va_end(args);
-
- DebugStr(CtoPstr((char*)dbugstr));
- }
-
- void Invert(Rect *foo) {
- InvertRect(foo);
- }
-
- void Right(Rect *baz) {
- PixMapHandle bar = GetGWorldPixMap(gBraveNewGWorld);
- unsigned long rbytes = bar[0]->rowBytes & 0x3FFF;
- Ptr data = GetPixBaseAddr(GetGWorldPixMap(gBraveNewGWorld));
- long x, y;
- unsigned long *pixelptr;
- char foo;
-
- if(!data) {
- DebugStr("\pthe pixbaseaddr of our gworld is nil");
- return;
- }
-
- for(y = baz->top; y < baz->bottom; y++) {
- for(x = baz->left; x < baz->right; x++) {
- pixelptr = (unsigned long*)(data + (y * rbytes) + (x * 4));
- foo = ((char*)pixelptr)[1];
- ((char*)pixelptr)[1] = ((char*)pixelptr)[2];
- ((char*)pixelptr)[2] = ((char*)pixelptr)[3];
- ((char*)pixelptr)[3] = foo;
- }
- }
- }
-
- void Left(Rect *baz) {
- PixMapHandle bar = GetGWorldPixMap(gBraveNewGWorld);
- unsigned long rbytes = bar[0]->rowBytes & 0x3FFF;
- Ptr data = GetPixBaseAddr(GetGWorldPixMap(gBraveNewGWorld));
- long x, y;
- unsigned long *pixelptr;
- char foo;
-
- if(!data) {
- DebugStr("\pthe pixbaseaddr of our gworld is nil");
- return;
- }
-
- for(y = baz->top; y < baz->bottom; y++) {
- for(x = baz->left; x < baz->right; x++) {
- pixelptr = (unsigned long*)(data + (y * rbytes) + (x * 4));
- foo = ((char*)pixelptr)[3];
- ((char*)pixelptr)[3] = ((char*)pixelptr)[2];
- ((char*)pixelptr)[2] = ((char*)pixelptr)[1];
- ((char*)pixelptr)[1] = foo;
- }
- }
- }
- void Nostalgia(Rect *baz) {
- PixMapHandle bar = GetGWorldPixMap(gBraveNewGWorld);
- unsigned long rbytes = bar[0]->rowBytes & 0x3FFF;
- Ptr data = GetPixBaseAddr(GetGWorldPixMap(gBraveNewGWorld));
- long x, y;
- unsigned long *pixelptr;
-
- if(!data) {
- DebugStr("\pthe pixbaseaddr of our gworld is nil");
- return;
- }
-
- for(y = baz->top; y < baz->bottom; y++) {
- for(x = baz->left; x < baz->right; x++) {
- long avg;
- unsigned long tempColor;
- unsigned char *tempColorPtr;
- pixelptr = (unsigned long*)(data + (y * rbytes) + (x * 4));
- avg = (((unsigned char*)pixelptr)[1] +
- ((unsigned char*)pixelptr)[2] +
- ((unsigned char*)pixelptr)[3]) / 3;
-
- avg *= 2;
-
- if (avg > 255) avg = 255;
- else if (avg < 0 ) avg = 0;
-
- tempColorPtr = (unsigned char*)&tempColor;
- tempColorPtr[0] = 0;
- tempColorPtr[1] = avg;
- tempColorPtr[2] = avg * 0.8;
- tempColorPtr[3] = avg * 0.44;
-
- *pixelptr = tempColor;
- }
- }
- }
-